Memory API Reference
The Memory API provides a provider-based abstraction for storing, retrieving, and managing application memory. Memory can be used for conversational context, user-specific information, preferences, application state, and other data that should persist beyond a single operation. This page documents the current Memory API and its relationship with agents, conversations, and Knowledge.Overview
BindAI memory is built around memory records and interchangeable providers. Conceptually:Memory Records
The primary unit of stored memory is aMemoryRecord.
A memory record can contain information such as:
- Key
- Value
- Namespace
- Type
- Metadata
- Importance
- Access count
- Last-accessed information
- Expiration
- Embedding
- Score
- Tags
- Source
- Relationships
- Related keys
- Creation and update timestamps
Memory Providers
BindAI separates memory storage behind provider implementations. Current providers include:InMemoryProviderSQLiteMemoryProviderPostgreSQLMemoryProviderVectorMemoryProviderPineconeMemoryProviderChromaMemoryProvider
Assigning Memory to an Agent
Memory can be attached when constructing an agent. For example:Memory Operations
The memory abstraction supports operations for managing records. Common operations include:- Set
- Get
- Search
- Check existence
- Delete
- Clear
Reading Memory
Applications can retrieve records from memory. A lookup may retrieve a specific record:Writing Memory
Applications can store information as memory records. For example, an application may store:- User preferences
- Important facts
- Conversation-related information
- Application state
- Long-lived context
- Derived information
Namespaces
Memory records can be organized using namespaces. Conceptually:Metadata
Memory records can contain metadata. Metadata can describe information such as:- Source
- Category
- User or application context
- Record type
- Additional filtering attributes
Search and Retrieval
Memory providers can support searching records. Depending on the provider, retrieval may involve:- Direct key lookup
- Metadata filtering
- Text-oriented search
- Vector similarity
- Provider-specific search mechanisms
Memory Results
Memory operations can return structured memory results. AMemoryResult can represent retrieved memory information and associated retrieval metadata.
Applications should use the result abstraction rather than assuming every provider returns the same underlying storage object.
Memory Management
BindAI provides memory-management concepts for controlling how records evolve over time. Memory management can include operations such as:- Touching a record
- Reinforcing important memory
- Weakening memory
- Applying decay
- Promoting records
- Forgetting records
- Setting expiration
- Clearing expiration
Importance and Access
Memory records can contain importance and access information. For example:Expiration
Memory records can have expiration information. Applications can use expiration to prevent information from remaining available indefinitely. Expiration is useful for:- Temporary context
- Short-lived preferences
- Cached information
- Time-sensitive application state
Tags and Relationships
Memory records can contain tags and relationship information. Conceptually:Serialization
Memory records may contain structured data that needs to be serialized for storage. Applications should prefer values that can be represented consistently by the selected provider. Provider-specific serialization behavior should be considered when storing complex Python objects.Conversation Memory
Conversation memory is an application-level use of the Memory abstraction. It should not be assumed that every memory provider automatically stores the complete transcript of every agent interaction. A conversation system can use memory records to represent information from previous interactions. Conceptually:Session Isolation
Applications should isolate memory between users, conversations, or other logical sessions when required. Namespaces, keys, metadata, and separate provider instances can be used as part of an isolation strategy. For example:Memory and Agent Execution
Memory can be combined with agent execution. Conceptually:Memory vs Execution Context
Memory and execution context have different purposes.
Execution context should not automatically be treated as persistent memory.
Memory vs Conversation History
Conversation history and Memory are related but distinct concepts. Conversation history represents messages exchanged during a conversation. Memory represents information deliberately stored for later retrieval or reuse. For example:Memory vs Knowledge
Memory and Knowledge solve different problems.
An agent can use both.
For example:
Memory in Workflows
Workflow-based applications can use Memory as a shared persistence layer where appropriate. Conceptually:Memory and Multi-Agent Systems
Multiple agents can use the same memory provider or separate memory instances. Shared memory can support collaboration:Provider Selection
Different providers are appropriate for different environments.In-memory
Useful for:- Development
- Tests
- Temporary applications
SQLite
Useful for:- Local applications
- Small deployments
- Persistent development environments
PostgreSQL
Useful for:- Server applications
- Shared persistent storage
- Production-oriented relational storage
Vector Memory
Useful when semantic retrieval is important.Pinecone
Useful for managed vector-backed memory deployments.Chroma
Useful for local or application-managed vector storage. Provider choice should consider persistence, scale, retrieval requirements, operational complexity, and deployment architecture.Resource Management
Persistent providers may hold resources such as database or client connections. Applications should release provider resources when they are no longer required. For example:Clearing Memory
Memory providers support clearing stored records. Clearing can be useful for:- Tests
- Conversation resets
- User-requested deletion
- Temporary environments
- Data lifecycle management
Error Handling
Memory operations can fail because of:- Storage errors
- Database connection failures
- Invalid data
- Provider configuration errors
- Network failures
- Missing records
- External vector-store failures
Performance
Memory retrieval should be designed around the amount and type of information being stored. Useful practices include:- Retrieve only relevant records.
- Use namespaces appropriately.
- Keep metadata consistent.
- Avoid unnecessarily large values.
- Use vector retrieval when semantic search is appropriate.
- Apply expiration where information is temporary.
- Avoid loading an entire memory store for every request.
Security
Memory can contain private or sensitive application information. Applications should:- Isolate users and sessions.
- Restrict provider access.
- Protect database credentials.
- Avoid storing unnecessary sensitive data.
- Apply appropriate retention policies.
- Support deletion where required.
- Protect memory retrieval from unauthorized access.
Testing
Memory providers should be tested independently from agents. Useful tests include:- Setting records
- Getting records
- Searching
- Metadata filtering
- Existence checks
- Deletion
- Clearing
- Expiration
- Relationships
- Provider failures
- Resource cleanup
- Namespace isolation
API Accuracy
The current Memory API should not be described as a generic automatic conversation-history mechanism. This documentation intentionally avoids assuming APIs such as:Best Practices
- Choose a provider appropriate for the deployment.
- Use namespaces to isolate logical memory scopes.
- Store useful information rather than every transient value.
- Keep Memory distinct from Knowledge.
- Keep Memory distinct from runtime execution context.
- Use metadata consistently.
- Apply expiration to temporary information.
- Protect stored data and provider credentials.
- Test providers independently.
- Release provider resources appropriately.
- Design shared memory access carefully in multi-agent systems.
Related APIs
The Memory API works closely with:- Agent
MemoryRecordMemoryResultMemoryManagerMemoryRegistry- Memory providers
- Knowledge
- Workflow
- Execution context
